﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IPC.Communication.ModBus;

namespace IPC.Communication.Profinet.Inovance
{
    public class InovanceSerial : ModbusRtu
    {
        public InovanceSeries Series
        {
            get;
            set;
        }

        public InovanceSerial()
        {
            Series = InovanceSeries.AM;
        }

        public InovanceSerial(byte station = 1)
            : base(station)
        {
            Series = InovanceSeries.AM;
        }

        public InovanceSerial(InovanceSeries series, byte station = 1)
            : base(station)
        {
            Series = series;
        }

        public override OperateResult<string> TranslateToModbusAddress(string address, byte modbusCode)
        {
            return InovanceHelper.PraseInovanceAddress(Series, address, modbusCode);
        }

        public override string ToString()
        {
            return String.Format("InovanceSerial<{0}>[{1}:{2}]", Series, base.PortName, base.BaudRate);
        }
    }
}